'use strict';

const Controller = require('egg').Controller;

class fileController extends Controller {
  async getFileHistory() {
    const { ctx } = this;
    const sessionInfo = ctx.session.sessionInfo;
    if (!sessionInfo.id) {
      ctx.body = await ctx.service.returnBody.index(null, '请登录！');
    }
    ctx.body = await ctx.service.file.getFileHistory(ctx.request.body);
  }
  async batchFile() {
    const { ctx } = this;
    const sessionInfo = ctx.session.sessionInfo;
    if (!sessionInfo.id) {
      ctx.body = await ctx.service.returnBody.index(null, '请登录！');
    }
    const parts = this.ctx.multipart({ autoFields: true });
    ctx.body = await ctx.service.file.batchFile(parts);
  }
}

module.exports = fileController;
